#include "data_collect.h"

/**************************************************************************************
功能描述: 初始化
修改记录:
**************************************************************************************/
int DATA_COLLECT_C::Init()
{
    if (0 != objLeftRs16LidarData_.Init()   ||
        0 != objLeftRsBpLidarData_.Init()   ||
        0 != objRightRsBpLidarData_.Init()  ||
        0 != objMiddleRs16LidarData_.Init() ||
        0 != objMiddleRsBpLidarData_.Init()) {
            ST_LOG_ERR("Lidar Data Collect Init Fail.");
            return -1;
    }

    if (0 != objFrontUpperImageData_.Init()   ||
        0 != objFrontLowerImageData_.Init()   ||
        0 != objFrontLeftImageData_.Init()    ||
        0 != objFrontRightImageData_.Init()   ||
        0 != objRearImageData_.Init()         ||
        0 != objRearLeftImageData_.Init()     ||
        0 != objRearLeftImageData_.Init()     ||
        0 != objTrafficLightImageData_.Init()) {
            ST_LOG_ERR("Image Data Collect Init Fail.");
            return -1;
    }

    return 0;
}

/**************************************************************************************
功能描述: 数据采集
修改记录:
**************************************************************************************/
void DATA_COLLECT_C::DataCollect()
{
    objNavReceiver_.Get(stNavState_);

    ST_LOG_INFO_SAMPLE_IF_TRUE(stNavState_.enPlanMoveTrend == PLAN_MOVE_TREND_STOP,
        20 * 60, "The Current Movement Trend State is Stop, Pause Data Collect.");

    if (stNavState_.enPlanMoveTrend == PLAN_MOVE_TREND_STOP) {
        return;
    }

    if (objCollectTimer_.IsTimeOut()) {
        objLeftRs16LidarData_.DataCollect();
        objLeftRsBpLidarData_.DataCollect();
        objRightRsBpLidarData_.DataCollect();
        objMiddleRs16LidarData_.DataCollect();
        objMiddleRsBpLidarData_.DataCollect();

        objLeftRadarData_.DataCollect();
        objFrontRadarData_.DataCollect();
        objRightRadarData_.DataCollect();
        objBackRadarData_.DataCollect();

        objFrontUpperImageData_.DataCollect();
        objFrontLowerImageData_.DataCollect();
        objFrontLeftImageData_.DataCollect();
        objFrontRightImageData_.DataCollect();
        objRearImageData_.DataCollect();
        objRearLeftImageData_.DataCollect();
        objRearRightImageData_.DataCollect();
        objTrafficLightImageData_.DataCollect();

        objCollectTimer_.Reset();
    }
}

